package com.yanqu.road.server.cmd.zhaoshang;

import com.yanqu.road.entity.zhaoshang.ZsWarReport;
import com.yanqu.road.logic.pb.ZhaoShangPb;
import com.yanqu.road.pb.zhaoshang.ZhaoShangProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.zhaoshang.ZsModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

import java.util.ArrayList;
import java.util.List;

@Cmd(code = Protocol.S_ZS_WAR_REPORT_SYNC_FROM_CROSS, desc = "战报同步校对")
public class ZsWarReportSyncCmdFromCross extends AbstractCommand {


    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ZhaoShangProto.ZsPlayerWarReportSyncMsgFromCross syncMsg = ZhaoShangProto.ZsPlayerWarReportSyncMsgFromCross.parseFrom(packet.getBytes());
        List<ZsWarReport> reportList = new ArrayList<>();
        for(ZhaoShangProto.ZsWarReportInfoTemp warReportInfoTemp : syncMsg.getReportListList()){
            reportList.add(ZhaoShangPb.parseToZsWarReport(warReportInfoTemp));
        }
        player.getModule(ZsModule.class).syncWarReportFromCross(reportList, true);
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
